Part Number Hot Search : 
1H100 B57500K 09012 BCR16C 1H100 1H100 PG101 3M34L
Product Description
Full Text Search
 

To Download PIC16F874 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
 M
* PIC16F870 * PIC16F871 * PIC16F872 * PIC16F873
PIC16F87X
Pin Diagram
PDIP, SOIC
MCLR/VPP RA0/AN0 RA1/AN1 RA2/AN2/VREF RA3/AN3/VREF RA4/T0CKI RA5/AN4/SS VSS OSC1/CLKIN OSC2/CLKOUT RC0/T1OSO/T1CKI RC1/T1OSI/CCP2 RC2/CCP1 RC3/SCK/SCL 1 2 3 4 5 6 7 8 9 10 11 12 13 14 28 27 26 25 24 23 22 21 20 19 18 17 16 15 RB7 RB6 RB5 RB4 RB3 RB2 RB1 RB0/INT VDD VSS RC7/RX/DT RC6/TX/CK RC5/SDO RC4/SDI/SDA
EEPROM Memory Programming Specification
This document includes the programming specifications for the following devices:
* PIC16F874 * PIC16F876 * PIC16F877
1.0
PROGRAMMING THE PIC16F87X
The PIC16F87X is programmed using a serial method. The Serial mode will allow the PIC16F87X to be programmed while in the user's system. This allows for increased design flexibility. This programming specification applies to PIC16F87X devices in all packages.
MCLR/VPP RA0/AN0 RA1/AN1 RA2/AN2/VREF RA3/AN3/VREF RA4/T0CKI RA5/AN4/SS RE0/RD/AN5 RE1/WR/AN6 RE2/CS/AN7 VDD VSS OSC1/CLKIN OSC2/CLKOUT RC0/T1OSO/T1CKI RC1/T1OSI/CCP2 RC2/CCP1 RC3/SCK/SCL RD0/PSP0 RD1/PSP1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
PIC16F876/873/872/870
40 39 38 37 36 35
RB7 RB6 RB5 RB4 RB3 RB2 RB1 RB0/INT VDD VSS RD7/PSP7 RD6/PSP6 RD5/PSP5 RD4/PSP4 RC7/RX/DT RC6/TX/CK RC5/SDO RC4/SDI/SDA RD3/PSP3 RD2/PSP2
1.1
PIC16F877/874/871
Programming Algorithm Requirements
The programming algorithm used depends on the operating voltage (VDD) of the PIC16F87X device. Algorithm 1 is designed for a VDD range of 2.2V VDD < 5.5V. Algorithm 2 is for a range of 4.5V VDD 5.5V. Either algorithm can be used with the two available programming entry methods. The first method follows the normal Microchip Programming mode entry of applying a VPP voltage of 13V .5V. The second method, called Low Voltage ICSPTM or LVP for short, applies VDD to MCLR and uses the I/O pin RB3 to enter Programming mode. When RB3 is driven to VDD from ground, the PIC16F87X device enters Programming mode.
34 33 32 31 30 29 28 27 26 25 24 23 22 21
1.2
Programming Mode
The Programming mode for the PIC16F87X allows programming of user program memory, data memory, special locations used for ID, and the configuration word.
2002 Microchip Technology Inc.
DS39025F-page 1
PIC16F87X
PIN DESCRIPTIONS (DURING PROGRAMMING): PIC16F87X
During Programming Pin Name Function RB3 RB6 RB7 MCLR VDD VSS PGM CLOCK DATA VTEST MODE VDD VSS Pin Type I I I/O P* P P Pin Description Low voltage ICSP programming input if LVP configuration bit equals 1 Clock input Data input/output Program Mode Select Power Supply Ground
Legend: I = Input, O = Output, P = Power * In the PIC16F87X, the programming high voltage is internally generated. To activate the Programming mode, high voltage needs to be applied to the MCLR input. Since the MCLR is used for a level source, this means that MCLR does not draw any significant current.
DS39025F-page 2
2002 Microchip Technology Inc.
PIC16F87X
2.0
2.1
PROGRAM MODE ENTRY
User Program Memory Map
The contents of data EEPROM memory have the capability to be embedded into the HEX file. The programmer should be able to read data EEPROM information from a HEX file and conversely (as an option), write data EEPROM contents to a HEX file, along with program memory information and configuration bit information. The 256 data memory locations are logically mapped starting at address 0x2100. The format for data memory storage is one data byte per address location, LSB aligned.
The user memory space extends from 0x0000 to 0x1FFF (8K). In Programming mode, the program memory space extends from 0x0000 to 0x3FFF, with the first half (0x0000-0x1FFF) being user program memory and the second half (0x2000-0x3FFF) being configuration memory. The PC will increment from 0x0000 to 0x1FFF and wrap to 0x0000, 0x2000 to 0x3FFF and wrap around to 0x2000 (not to 0x0000). Once in configuration memory, the highest bit of the PC stays a `1', thus always pointing to the configuration memory. The only way to point to user program memory is to reset the part and re-enter Program/Verify mode, as described in Section 2.4. In the configuration memory space, 0x2000-0x200F are physically implemented. However, only locations 0x2000 through 0x2007 are available. Other locations are reserved. Locations beyond 0x200F will physically access user memory (see Figure 2-1).
2.3
ID Locations
A user may store identification information (ID) in four ID locations. The ID locations are mapped in [0x2000 : 0x2003]. It is recommended that the user use only the four Least Significant bits of each ID location. In some devices, the ID locations read out in an unscrambled fashion after code protection is enabled. For these devices, it is recommended that ID location is written as "11 1111 1000 bbbb" where `bbbb' is ID information. In other devices, the ID locations read out normally, even after code protection. To understand how the devices behave, refer to Table 5-1. To understand the scrambling mechanism after code protection, refer to Section 4.0.
2.2
Data EEPROM Memory
The EEPROM data memory space is a separate block of high endurance memory that the user accesses using a special sequence of instructions. The amount of data EEPROM memory depends on the device and is shown below in number of bytes. Device PIC16F870 PIC16F871 PIC16F872 PIC16F873 PIC16F874 PIC16F876 PIC16F877 # of Bytes 64 64 64 128 128 256 256
2002 Microchip Technology Inc.
DS39025F-page 3
PIC16F87X
TABLE 2-1: PROGRAM MEMORY MAPPING
2K words 4K words 8K words
2000h 2001h 2002h 2003h 2004h 2005h 2006h 2007h
ID Location ID Location ID Location ID Location Reserved Reserved Device ID Configuration Word
0h 1FFh 3FFh 400h 7FFh 800h BFFh C00h FFFh 1000h
Implemented Implemented
Implemented Implemented Implemented Implemented
Implemented Implemented Implemented Implemented Implemented
Reserved Reserved
Implemented Implemented Implemented
1FFFh
2008h
Reserved
Reserved
Reserved
2100h
Reserved
Reserved
Reserved
3FFFh
DS39025F-page 4
2002 Microchip Technology Inc.
PIC16F87X
2.4 Program/Verify Mode
2.4.2
The Program/Verify mode is entered by holding pins RB6 and RB7 low, while raising MCLR pin from VIL to VIHH (high voltage). In this mode, the state of the RB3 pin does not effect programming. Low voltage ICSP Programming mode is entered by raising RB3 from VIL to VDD and then applying VDD to MCLR. Once in this mode, the user program memory and the configuration memory can be accessed and programmed in serial fashion. The mode of operation is serial, and the memory that is accessed is the user program memory. RB6 and RB7 are Schmitt Trigger Inputs in this mode. Note: The OSC must not have 72 osc clocks while the device MCLR is between VIL and VIHH.
SERIAL PROGRAM/VERIFY OPERATION
The sequence that enters the device into the Programming/Verify mode places all other logic into the RESET state (the MCLR pin was initially at VIL). This means that all I/O are in the RESET state (high impedance inputs). The normal sequence for programming is to use the load data command to set a value to be written at the selected address. Issue the begin programming command followed by read data command to verify, and then increment the address. A device RESET will clear the PC and set the address to 0. The "increment address" command will increment the PC. The "load configuration" command will set the PC to 0x2000. The available commands are shown in Table 2-2.
The RB6 pin is used as a clock input pin, and the RB7 pin is used for entering command bits and data input/output during serial operation. To input a command, the clock pin (RB6) is cycled six times. Each command bit is latched on the falling edge of the clock, with the Least Significant bit (LSb) of the command being input first. The data on pin RB7 is required to have a minimum setup and hold time (see AC/DC specifications), with respect to the falling edge of the clock. Commands that have data associated with them (read and load) are specified to have a minimum delay of 1 s between the command and the data. After this delay, the clock pin is cycled 16 times with the first cycle being a START bit and the last cycle being a STOP bit. Data is also input and output LSb first. Therefore, during a read operation, the LSb will be transmitted onto pin RB7 on the rising edge of the second cycle, and during a load operation, the LSb will be latched on the falling edge of the second cycle. A minimum 1 s delay is also specified between consecutive commands. All commands are transmitted LSb first. Data words are also transmitted LSb first. The data is transmitted on the rising edge and latched on the falling edge of the clock. To allow for decoding of commands and reversal of data pin configuration, a time separation of at least 1 s is required between a command and a data word (or another command). The commands that are available are:
2.4.1
LOW VOLTAGE ICSP PROGRAMMING MODE
2.4.2.1
Load Configuration
Low voltage ICSP Programming mode allows a PIC16F87X device to be programmed using VDD only. However, when this mode is enabled by a configuration bit (LVP), the PIC16F87X device dedicates RB3 to control entry/exit into Programming mode. When LVP bit is set to `1', the low voltage ICSP programming entry is enabled. Since the LVP configuration bit allows low voltage ICSP programming entry in its erased state, an erased device will have the LVP bit enabled at the factory. While LVP is `1', RB3 is dedicated to low voltage ICSP programming. Bring RB3 to VDD and then MCLR to VDD to enter programming mode. All other specifications for high voltage ICSPTM apply. To disable low voltage ICSP mode, the LVP bit must be programmed to `0'. This must be done while entered with High Voltage Entry mode (LVP bit = 1). RB3 is now a general purpose I/O pin.
After receiving this command, the program counter (PC) will be set to 0x2000. By then applying 16 cycles to the clock pin, the chip will load 14-bits in a "data word," as described above, to be programmed into the configuration memory. A description of the memory mapping schemes of the program memory for normal operation and Configuration mode operation is shown in Figure 2-1. After the configuration memory is entered, the only way to get back to the user program memory is to exit the Program/Verify Test mode by taking MCLR low (VIL).
2.4.2.2
Load Data for Program Memory
After receiving this command, the chip will load in a 14-bit "data word" when 16 cycles are applied, as described previously. A timing diagram for the load data command is shown in Figure 6-1.
2002 Microchip Technology Inc.
DS39025F-page 5
PIC16F87X
2.4.2.3 Load Data for Data Memory 2.4.2.6 Increment Address
After receiving this command, the chip will load in a 14-bit "data word" when 16 cycles are applied. However, the data memory is only 8-bits wide, and thus, only the first 8-bits of data after the START bit will be programmed into the data memory. It is still necessary to cycle the clock the full 16 cycles in order to allow the internal circuitry to reset properly. The data memory contains up to 256 bytes. If the device is code protected, the data is read as all zeros. The PC is incremented when this command is received. A timing diagram of this command is shown in Figure 6-3.
2.4.2.7
Begin Erase/Program Cycle
2.4.2.4
Read Data from Program Memory
After receiving this command, the chip will transmit data bits out of the program memory (user or configuration) currently accessed, starting with the second rising edge of the clock input. The RB7 pin will go into Output mode on the second rising clock edge, and it will revert back to Input mode (hi-impedance) after the 16th rising edge. A timing diagram of this command is shown in Figure 6-2.
A load command must be given before every begin programming command. Programming of the appropriate memory (test program memory, user program memory or data memory) will begin after this command is received and decoded. An internal timing mechanism executes an erase before write. The user must allow for both erase and programming cycle times for programming to complete. No "end programming" command is required.
2.4.2.8
Note:
Begin Programming
The Begin Program operation must take place at 4.5 to 5.5 VDD range.
2.4.2.5
Read Data from Data Memory
After receiving this command, the chip will transmit data bits out of the data memory starting with the second rising edge of the clock input. The RB7 pin will go into Output mode on the second rising edge, and it will revert back to Input mode (hi-impedance) after the 16th rising edge. As previously stated, the data memory is 8-bits wide, and therefore, only the first 8-bits that are output are actual data.
A load command must be given before every begin programming command. Programming of the appropriate memory (test program memory, user program memory or data memory) will begin after this command is received and decoded. An internal timing mechanism executes a write. The user must allow for program cycle time for programming to complete. No "end programming" command is required. This command is similar to the ERASE/PROGRAM CYCLE command, except that a word erase is not done. It is recommended that a bulk erase be performed before starting a series of programming only cycles.
TABLE 2-2:
COMMAND MAPPING FOR PIC16F87X
Mapping (MSB ... LSB) X X X X 0 0 X X 0 0 X X X X 0 1 X X 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 0 1 0 1 0 1 0 1 0 0 1 0 0 1 0 0 0 0 0 0 1 1 1 1 0, data (14), 0 0, data (14), 0 Data 0, data (14), 0 0, data (14), 0 0, data (14), 0 Voltage Range 2.2V - 5.5V 2.2V - 5.5V 2.2V - 5.5V 2.2V - 5.5V 2.2V - 5.5V 4.5V - 5.5V 2.2V - 5.5V 2.2V - 5.5V 4.5V - 5.5V 4.5V - 5.5V
Command Load Configuration Load Data for Program Memory Read Data from Program Memory Increment Address Begin Erase Programming Cycle Begin Programming Only Cycle Load Data for Data Memory Read Data from Data Memory Bulk Erase Setup1 Bulk Erase Setup2
DS39025F-page 6
2002 Microchip Technology Inc.
PIC16F87X
2.5 Erasing Program and Data Memory
2.5.2 ERASING CODE PROTECTED MEMORY
Depending on the state of the code protection bits, program and data memory will be erased using different procedures. The first set of procedures is used when both program and data memories are not code protected. The second set of procedures must be used when either memory is code protected. A device programmer should determine the state of the code protection bits and then apply the proper procedure to erase the desired memory.
2.5.1
ERASING NON-CODE PROTECTED PROGRAM AND DATA MEMORY
For the PIC16F87X devices, once code protection is enabled, all protected program and data memory locations read all '0's and further programming is disabled. The ID locations and configuration word read out unscrambled and can be reprogrammed normally. The only procedure to erase a PIC16F87X device that is code protected is shown in the following procedure. This method erases program memory, data memory, configuration bits and ID locations. Since all data within the program and data memory will be erased when this procedure is executed, the security of the data or code is not compromised. 1. 2. Execute a Load Configuration command (000000) with a '1' in all locations (0x3FFF) Execute Increment Address command (000110) to set address to configuration word location (0x2007) Execute a Bulk Erase Setup1 command (000001) Execute a Bulk Erase Setup2 command (000111) Execute a Begin Erase/Programming command (001000) Wait 8 ms Execute a Bulk Erase Setup1 command (000001) Execute a Bulk Erase Setup2 command (000111)
When both program and data memories are not code protected, they must be individually erased using the following procedures. The only way that both memories are erased using a single procedure is if code protection is enabled for one of the memories. These procedures do not erase the configuration word or ID locations. Procedure to bulk erase program memory: 1. Execute a Load Data for Program Memory command (000010) with a '1' in all locations (0x3FFF) Execute a Bulk Erase Setup1 command (000001) Execute a Bulk Erase Setup2 command (000111) Execute a Begin Erase/Programming command (001000) Wait 8 ms Execute a Bulk Erase Setup1 command (000001) Execute a Bulk Erase Setup2 command (000111) Execute a Load Data for Data Memory command (000011) with a '1' in all locations (0x3FFF) Execute a Bulk Erase Setup1 command (000001) Execute a Bulk Erase Setup2 command (000111) Execute a Begin Erase/Programming command (001000) Wait 8 ms Execute a Bulk Erase Setup1 command (000001) Execute a Bulk Erase Setup2 command (000111)
3. 4. 5. 6. 7. 8.
2. 3. 4. 5. 6. 7.
Procedure to bulk erase data memory: 1.
2. 3. 4. 5. 6. 7.
2002 Microchip Technology Inc.
DS39025F-page 7
PIC16F87X
FIGURE 2-1: FLOW CHART - PIC16F87X PROGRAM MEMORY (2.2V VDD < 5.5V)
START
Set VDD = VDDP
Load Data Command
Begin Erase/Programming Command
Wait tera + tprog
Increment Address Command
No
All Locations Done?
Verify all Locations
Report Verify Error
No
Data Correct?
DONE
DS39025F-page 8
2002 Microchip Technology Inc.
PIC16F87X
FIGURE 2-2: FLOW CHART - PIC16F87X PROGRAM MEMORY (4.5V VDD 5.5V)
START
Bulk Erase Sequence
Set VDD = VDDP
Load Data Command
Begin Programming Only Command
Wait tprog
Increment Address Command
No
All Locations Done?
Verify all Locations
Report Verify Error
No
Data Correct?
DONE
2002 Microchip Technology Inc.
DS39025F-page 9
PIC16F87X
FIGURE 2-3: FLOW CHART - PIC16F87X CONFIGURATION MEMORY (2.2V VDD < 5.5V)
START
Load Configuration Data
No
Program ID Location?
Yes Program Cycle
Read Data Command
Increment Address Command
Report Programming Failure
No Data Correct? Yes
No
Address = 0x2004? Yes Increment Address Command
PROGRAM CYCLE Load Data Command
Increment Address Command
Begin Erase/Program Command
Increment Address Command
Program Cycle (Config. Word)
Wait tera + tprog
Report Program Configuration Word Error
No
Data Correct? Yes
Read Data Command
DONE
DS39025F-page 10
2002 Microchip Technology Inc.
PIC16F87X
FIGURE 2-4: FLOW CHART - PIC16F87X CONFIGURATION MEMORY
START
Load Configuration Data
No
Program ID Location?
Yes Program Cycle
Read Data Command
Increment Address Command
Report Programming Failure
No Data Correct? Yes
No
Address = 0x2004? Yes Increment Address Command
PROGRAM CYCLE Load Data Command
Increment Address Command
Begin Program Only Command*
Increment Address Command
Program Cycle (Config. Word)
Wait tprog Report Program Configuration Word Error No Data Correct? Yes Read Data Command
DONE
* Assumes that a bulk erase was issued before programming configuration word. If not, use the program flow from Figure 2-4.
2002 Microchip Technology Inc.
DS39025F-page 11
PIC16F87X
3.0 CONFIGURATION WORD
TABLE 3-1:
Device Dev PIC16F870 00 1101 000 00 1101 001 00 1000 111 00 1001 011 00 1001 001 00 1001 111 00 1001 101 PIC16F871 PIC16F872 PIC16F873 PIC16F874 PIC16F876 PIC16F877 Rev x xxxx x xxxx x xxxx x xxxx x xxxx x xxxx x xxxx
DEVICE ID VALUE
Device ID Value
The PIC16F87X has several configuration bits. These bits can be set (reads `0'), or left unchanged (reads `1'), to select various device configurations.
3.1
Device ID Word
The device ID word for the PIC16F87X is located at 2006h.
DS39025F-page 12
2002 Microchip Technology Inc.
PIC16F87X
REGISTER 3-1:
U-0 CP1 bit 13 bit 13-12 bit 5-4 CP1:CP0: FLASH Program Memory Code Protection bits(2) 4 K Devices: 11 = Code protection off 10 = 0F00h to 0FFFh code protected 01 = 0800h to 0FFFh code protected 00 = 0000h to 0FFFh code protected 8 K Devices: 11 = Code protection off 10 = 1F00h to 1FFFh code protected 01 = 1000h to 1FFFh code protected 00 = 0000h to 1FFFh code protected Reserved: Set to `1' for normal operation Unimplemented: Read as `1' WRT: FLASH Program Memory Write Enable bit 1 = Unprotected program memory may be written to by EECON control 0 = Unprotected program memory may not be written to by EECON control CPD: Data EE Memory Code Protection bit 1 = Code protection off 0 = Data EE memory code protected LVP: Low Voltage ICSP Programming Enable bit 1 = RB3/PGM pin has PGM function, low voltage programming enabled 0 = RB3 is digital I/O, HV on MCLR must be used for programming BODEN: Brown-out Reset Enable bit(2) 1 = BOR enabled 0 = BOR disabled PWRTE: Power-up Timer Enable bit 1 = PWRT disabled 0 = PWRT enabled WDTE: Watchdog Timer Enable bit 1 = WDT enabled 0 = WDT disabled FOSC1:FOSC0: Oscillator Selection bits 11 = RC oscillator 10 = HS oscillator 01 = XT oscillator 00 = LP oscillator Note 1: Enabling Brown-out Reset automatically enables Power-up Timer (PWRT), regardless of the value of bit PWRTE. Ensure the Power-up Timer is enabled any time Brown-out Reset is enabled. 2: All of the CP1:CP0 pairs have to be given the same value to enable the code protection scheme listed. Legend: R = Readable bit P = Programmable bit U = Unimplemented bit, read as `0' u = Unchanged from programmed state - n = Value when device is unprogrammed U-0 CP0 U-0 RESV
CONFIG: CONFIGURATION WORD FOR PIC16F873/874/876/877 (ADDRESS 2007h)
U-0 -- U-0 WRT U-0 CPD U-0 LVP R/P-1 BODEN U-0 CP1 R/P-1 CP0 R/P-1 PWRTE R/P-1 WDTE R/P-1 F0SC1 R/P-1 F0SC0 bit 0
bit 11 bit 10 bit 9
bit 8
bit 7
bit 6
bit 3
bit 2
bit 1-0
2002 Microchip Technology Inc.
DS39025F-page 13
PIC16F87X
REGISTER 3-2:
U-0 CP1 bit 13 bit 13-12 bit 5-4 CP1:CP0: FLASH Program Memory Code Protection bits(2) 11 = Code protection off 10 = Not supported 01 = Not supported 00 = 0000h to 07FFh code protected Reserved: Set to `1' for normal operation Unimplemented: Read as `1' WRT: FLASH Program Memory Write Enable bit 1 = Unprotected program memory may be written to by EECON control 0 = Unprotected program memory may not be written to by EECON control CPD: Data EE Memory Code Protection bit 1 = Code protection off 0 = Data EE memory code protected LVP: Low Voltage ICSP Programming Enable bit 1 = RB3/PGM pin has PGM function, low voltage programming enabled 0 = RB3 is digital I/O, HV on MCLR must be used for programming BODEN: Brown-out Reset Enable bit(2) 1 = BOR enabled 0 = BOR disabled PWRTE: Power-up Timer Enable bit 1 = PWRT disabled 0 = PWRT enabled WDTE: Watchdog Timer Enable bit 1 = WDT enabled 0 = WDT disabled FOSC1:FOSC0: Oscillator Selection bits 11 = RC oscillator 10 = HS oscillator 01 = XT oscillator 00 = LP oscillator Note 1: Enabling Brown-out Reset automatically enables Power-up Timer (PWRT), regardless of the value of bit PWRTE. Ensure the Power-up Timer is enabled any time Brown-out Reset is enabled. 2: All of the CP1:CP0 pairs have to be given the same value to enable the code protection scheme listed. Legend: R = Readable bit P = Programmable bit U = Unimplemented bit, read as `0' u = Unchanged from programmed state - n = Value when device is unprogrammed U-0 CP0 U-0 RESV
CONFIG: CONFIGURATION WORD FOR PIC16F870/871/872 (ADDRESS 2007h)
U-0 -- U-0 WRT U-0 CPD U-0 LVP R/P-1 BODEN U-0 CP1 R/P-1 CP0 R/P-1 PWRTE R/P-1 WDTE R/P-1 F0SC1 R/P-1 F0SC0 bit 0
bit 11 bit 10 bit 9
bit 8
bit 7
bit 6
bit 3
bit 2
bit 1-0
DS39025F-page 14
2002 Microchip Technology Inc.
PIC16F87X
4.0 EMBEDDING THE CONFIGURATION WORD AND ID INFORMATION IN THE HEX FILE
To allow portability of code, the programmer is required to read the configuration word and ID locations from the HEX file when loading the HEX file. If configuration word information was not present in the HEX file, then a simple warning message may be issued. Similarly, while saving a HEX file, configuration word and ID information must be included. An option to not include this information may be provided. Specifically for the PIC16F87X, the EEPROM data memory should also be embedded in the HEX file (see Section 2.2). Microchip Technology Inc. feels strongly that this feature is important for the benefit of the end customer.
2002 Microchip Technology Inc.
DS39025F-page 15
PIC16F87X
5.0 CHECKSUM COMPUTATION
The Least Significant 16 bits of this sum are the checksum. The following table describes how to calculate the checksum for each device. Note that the checksum calculation differs depending on the code protect setting. Since the program memory locations read out differently depending on the code protect setting, the table describes how to manipulate the actual program memory values to simulate the values that would be read from a protected device. When calculating a checksum by reading a device, the entire program memory can simply be read and summed. The configuration word and ID locations can always be read. Note that some older devices have an additional value added in the checksum. This is to maintain compatibility with older device programmer checksums. Checksum is calculated by reading the contents of the PIC16F87X memory locations and adding up the opcodes, up to the maximum user addressable location, e.g., 0x1FF for the PIC16F87X. Any carry bits exceeding 16-bits are neglected. Finally, the configuration word (appropriately masked) is added to the checksum. Checksum computation for each member of the PIC16F87X devices is shown in Table 5-1. The checksum is calculated by summing the following: * The contents of all program memory locations * The configuration word, appropriately masked * Masked ID locations (when applicable)
DS39025F-page 16
2002 Microchip Technology Inc.
PIC16F87X
TABLE 5-1:
Device PIC16F870 PIC16F871 PIC16F872 PIC16F873
CHECKSUM COMPUTATION
Code Protect OFF ALL OFF ALL OFF ALL OFF 0x0F00 : 0xFFF 0x0800 : 0xFFF ALL Checksum* SUM[0x0000:0x07FFF] + CFGW & 0x3BFF CFGW & 0x3BFF + SUM_ID SUM[0x0000:0x07FFF] + CFGW & 0x3BFF CFGW & 0x3BFF + SUM_ID SUM[0x0000:0x07FFF] + CFGW & 0x3BFF CFGW & 0x3BFF + SUM_ID SUM[0x0000:0x0FFF] + CFGW & 0x3BFF SUM[0x0000:0x0EFF] + CFGW & 0x3BFF +SUM_ID SUM[0x0000:0x07FF] + CFGW & 0x3BFF + SUM_ID CFGW & 0x3BFF + SUM_ID SUM[0x0000:0x0FFF] + CFGW & 0x3BFF SUM[0x0000:0x0EFF] + CFGW & 0x3BFF +SUM_ID SUM[0x0000:0x07FF] + CFGW & 0x3BFF + SUM_ID CFGW & 0x3BFF + SUM_ID SUM[0x0000:0x1FFF] + CFGW & 0x3BFF SUM[0x0000:0x1EFF] + CFGW & 0x3BFF +SUM_ID SUM[0x0000:0x0FFF] + CFGW & 0x3BFF + SUM_ID CFGW & 0x3BFF + SUM_ID SUM[0x0000:0x1FFF] + CFGW & 0x3BFF SUM[0x0000:0x1EFF] + CFGW & 0x3BFF +SUM_ID SUM[0x0000:0x0FFF] + CFGW & 0x3BFF + SUM_ID CFGW & 0x3BFF + SUM_ID Blank Value 0x33FF 0x3FCE 0x33FF 0x3FCE 0x33FF 0x3FCE 0x2BFF 0x48EE 0x3FDE 0x37CE 0x2BFF 0x48EE 0x3FDE 0x37CE 0x1BFF 0x28EE 0x27DE 0x27CE 0x1BFF 0x28EE 0x27DE 0x27CE 0x25E6 at 0 and max address 0xFFCD 0x0B9C 0xFFCD 0x0B9C 0xFFCD 0x0B9C 0xF7CD 0xFAA3 0xF193 0x039C 0xF7CD 0xFAA3 0xF193 0x039C 0xE7CD 0xDAA3 0xD993 0xF39C 0xE7CD 0xDAA3 0xD993 0xF39C
PIC16F874
OFF 0x0F00 : 0xFFF 0x0800 : 0xFFF ALL
PIC16F876
OFF 0x1F00 : 0x1FFF 0x1000 : 0x1FFF ALL
PIC16F877
OFF 0x1F00 : 0x1FFF 0x1000 : 0x1FFF ALL
Legend: CFGW SUM[a:b] SUM_ID
= Configuration Word = [Sum of locations a to b inclusive] = ID locations masked by 0xF then made into a 16-bit value with ID0 as the most significant nibble. For example, ID0 = 0x1, ID1 = 0x2, ID3 = 0x3, ID4 = 0x4, then SUM_ID = 0x1234 *Checksum = [Sum of all the individual expressions] MODULO [0xFFFF] + = Addition & = Bitwise AND
2002 Microchip Technology Inc.
DS39025F-page 17
PIC16F87X
6.0 PROGRAM/VERIFY MODE ELECTRICAL CHARACTERISTICS
TIMING REQUIREMENTS FOR PROGRAM/VERIFY MODE
Standard Operating Conditions (unless otherwise stated) Operating Temperature: 0C TA +70C Operating Voltage: 2.2V VDD 5.5V Sym Min Typ Max Units Conditions/Comments
TABLE 6-1:
AC/DC CHARACTERISTICS Characteristics General VDD level for Algorithm 1 VDD level for Algorithm 2 High voltage on MCLR for high voltage programming entry Voltage on MCLR for low voltage ICSP programming entry MCLR rise time (VSS to VHH) for Test mode entry (RB6, RB7) input high level (RB6, RB7) input low level RB<7:6> setup time before MCLR RB<7:6> hold time after MCLR RB3 setup time before MCLR Serial Program/Verify Data in setup time before clock Data in hold time after clock Data input not driven to next clock input (delay required between command/data or command/command) Delay between clock to clock of next command or data Clock to data out valid (during read data) Erase cycle time Programming cycle time
VDD VDD VIHH VIH tVHHR VIH1 VIL1 tset0 thld0 tset2 tset1 thld1 tdly1
2.2 4.5 VDD + 3.5 2.2
5.5 5.5 13.5 5.5 1.0
V V V V
s
Limited command set (See Table 2-2) All commands available
0.8 VDD 0.2 VDD 100 5 100 100 100 1.0
V V ns
s
Schmitt Trigger input Schmitt Trigger input
ns ns ns
s
tdly2 tdly3 tera tprog
1.0 80 2 2 4 4
s
ns ms ms
DS39025F-page 18
2002 Microchip Technology Inc.
PIC16F87X
FIGURE 6-1:
VIHH MCLR tset0 RB6 (Clock) RB7 (Data)
1 2 3 4 5 6
LOAD DATA COMMAND MCLR = VIHH (PROGRAM/VERIFY)
1 s min. tdly2
1 2 3 4 5 15 16
thld0
0 1 0 0 X X strt_bit stp_bit
tset1 thld1 } }
tdly1 1 s min.
tset1 thld1 } }
100 ns min. RESET
100 ns min. Program/Verify Test Mode
FIGURE 6-2:
VIHH MCLR tset0 RB6 (Clock) RB7 (Data)
READ DATA COMMAND MCLR = VIHH (PROGRAM/VERIFY)
tdly2 thld0
1 2 3 4 5 6
1 s min.
1
2
3
4
5
15
16
tdly3
0 0 1 0 X X strt_bit stp_bit
tset1 thld1 100 ns min. RB7 = input
tdly1 1 s min. RB7 = output RB7 input
} }
RESET
Program/Verify Test Mode
FIGURE 6-3:
INCREMENT ADDRESS COMMAND MCLR = VIHH (PROGRAM/VERIFY)
VIHH
MCLR
1 2 3 4 5 6
tdly2 1 s min.
1
Next Command
2
RB6 (Clock) RB7 (Data)
0
1
1
0
X
X
X
0
tset1 thld1 100 ns min. RESET Program/Verify Test Mode
tdly1 1 s min.
} }
2002 Microchip Technology Inc.
DS39025F-page 19
PIC16F87X
FIGURE 6-4:
VIH MCLR tset0 RB6 (Clock) RB7 (Data)
1 2 3 4 5 6
LOAD DATA COMMAND MCLR = VDD (PROGRAM/VERIFY)
1 s min. tdly2
1 2 3 4 5 15 16
thld0
0 1 0 0 X X strt_bit stp_bit
tset1 tset2 } } thld1
tdly1 1 s min.
tset1 thld1 } }
100 ns min. RB3 RESET
100 ns min.
Program/Verify Test Mode
FIGURE 6-5:
VIH MCLR tset0 RB6 (Clock) RB7 (Data)
READ DATA COMMAND MCLR = VDD (PROGRAM/VERIFY)
tdly2 thld0
1 2 3 4 5 6
1 s min.
1
2
3
4
5
15
16
tdly3
0 0 1 0 X X strt_bit stp_bit
tset1 thld1
tdly1 1 s min. RB7 = input RB7 = output RB7 input
} }
100 ns min.
tset2
RB3 RESET Program/Verify Test Mode
FIGURE 6-6:
INCREMENT ADDRESS COMMAND MCLR = VDD (PROGRAM/VERIFY)
VIH
MCLR
1 2 3 4 5 6
tdly2 1 s min.
1
Next Command
2
RB6 (Clock) RB7 (Data) tset2 100 ns min. RB3 RESET Program/Verify Test Mode
0
1
1
0
X
X
X
0
tset1 thld1
tdly1 1 s min.
} }
DS39025F-page 20
2002 Microchip Technology Inc.
Note the following details of the code protection feature on PICmicro(R) MCUs. * * * The PICmicro family meets the specifications contained in the Microchip Data Sheet. Microchip believes that its family of PICmicro microcontrollers is one of the most secure products of its kind on the market today, when used in the intended manner and under normal conditions. There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our knowledge, require using the PICmicro microcontroller in a manner outside the operating specifications contained in the data sheet. The person doing so may be engaged in theft of intellectual property. Microchip is willing to work with the customer who is concerned about the integrity of their code. Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not mean that we are guaranteeing the product as "unbreakable". Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our product.
* * *
If you have any further questions about this matter, please contact the local sales office nearest to you.
Information contained in this publication regarding device applications and the like is intended through suggestion only and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. No representation or warranty is given and no liability is assumed by Microchip Technology Incorporated with respect to the accuracy or use of such information, or infringement of patents or other intellectual property rights arising from such use or otherwise. Use of Microchip's products as critical components in life support systems is not authorized except with express written approval by Microchip. No licenses are conveyed, implicitly or otherwise, under any intellectual property rights.
Trademarks The Microchip name and logo, the Microchip logo, FilterLab, KEELOQ, microID, MPLAB, PIC, PICmicro, PICMASTER, PICSTART, PRO MATE, SEEVAL and The Embedded Control Solutions Company are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. dsPIC, ECONOMONITOR, FanSense, FlexROM, fuzzyLAB, In-Circuit Serial Programming, ICSP, ICEPIC, microPort, Migratable Memory, MPASM, MPLIB, MPLINK, MPSIM, MXDEV, PICC, PICDEM, PICDEM.net, rfPIC, Select Mode and Total Endurance are trademarks of Microchip Technology Incorporated in the U.S.A. Serialized Quick Term Programming (SQTP) is a service mark of Microchip Technology Incorporated in the U.S.A. All other trademarks mentioned herein are property of their respective companies. (c) 2002, Microchip Technology Incorporated, Printed in the U.S.A., All Rights Reserved.
Printed on recycled paper.
Microchip received QS-9000 quality system certification for its worldwide headquarters, design and wafer fabrication facilities in Chandler and Tempe, Arizona in July 1999. The Company's quality system processes and procedures are QS-9000 compliant for its PICmicro(R) 8-bit MCUs, KEELOQ(R) code hopping devices, Serial EEPROMs and microperipheral products. In addition, Microchip's quality system for the design and manufacture of development systems is ISO 9001 certified.
2002 Microchip Technology Inc.
DS39025F - page 21
M
WORLDWIDE SALES AND SERVICE
AMERICAS
Corporate Office
2355 West Chandler Blvd. Chandler, AZ 85224-6199 Tel: 480-792-7200 Fax: 480-792-7277 Technical Support: 480-792-7627 Web Address: http://www.microchip.com
ASIA/PACIFIC
Australia
Microchip Technology Australia Pty Ltd Suite 22, 41 Rawson Street Epping 2121, NSW Australia Tel: 61-2-9868-6733 Fax: 61-2-9868-6755
Japan
Microchip Technology Japan K.K. Benex S-1 6F 3-18-20, Shinyokohama Kohoku-Ku, Yokohama-shi Kanagawa, 222-0033, Japan Tel: 81-45-471- 6166 Fax: 81-45-471-6122
Rocky Mountain
2355 West Chandler Blvd. Chandler, AZ 85224-6199 Tel: 480-792-7966 Fax: 480-792-7456
China - Beijing
Microchip Technology Consulting (Shanghai) Co., Ltd., Beijing Liaison Office Unit 915 Bei Hai Wan Tai Bldg. No. 6 Chaoyangmen Beidajie Beijing, 100027, No. China Tel: 86-10-85282100 Fax: 86-10-85282104
Korea
Microchip Technology Korea 168-1, Youngbo Bldg. 3 Floor Samsung-Dong, Kangnam-Ku Seoul, Korea 135-882 Tel: 82-2-554-7200 Fax: 82-2-558-5934
Atlanta
500 Sugar Mill Road, Suite 200B Atlanta, GA 30350 Tel: 770-640-0034 Fax: 770-640-0307
Singapore
Microchip Technology Singapore Pte Ltd. 200 Middle Road #07-02 Prime Centre Singapore, 188980 Tel: 65-6334-8870 Fax: 65-6334-8850
Boston
2 Lan Drive, Suite 120 Westford, MA 01886 Tel: 978-692-3848 Fax: 978-692-3821
China - Chengdu
Microchip Technology Consulting (Shanghai) Co., Ltd., Chengdu Liaison Office Rm. 2401, 24th Floor, Ming Xing Financial Tower No. 88 TIDU Street Chengdu 610016, China Tel: 86-28-6766200 Fax: 86-28-6766599
Taiwan
Microchip Technology Taiwan 11F-3, No. 207 Tung Hua North Road Taipei, 105, Taiwan Tel: 886-2-2717-7175 Fax: 886-2-2545-0139
Chicago
333 Pierce Road, Suite 180 Itasca, IL 60143 Tel: 630-285-0071 Fax: 630-285-0075
Dallas
4570 Westgrove Drive, Suite 160 Addison, TX 75001 Tel: 972-818-7423 Fax: 972-818-2924
China - Fuzhou
Microchip Technology Consulting (Shanghai) Co., Ltd., Fuzhou Liaison Office Unit 28F, World Trade Plaza No. 71 Wusi Road Fuzhou 350001, China Tel: 86-591-7503506 Fax: 86-591-7503521
EUROPE
Denmark
Microchip Technology Nordic ApS Regus Business Centre Lautrup hoj 1-3 Ballerup DK-2750 Denmark Tel: 45 4420 9895 Fax: 45 4420 9910
Detroit
Tri-Atria Office Building 32255 Northwestern Highway, Suite 190 Farmington Hills, MI 48334 Tel: 248-538-2250 Fax: 248-538-2260
China - Shanghai
Microchip Technology Consulting (Shanghai) Co., Ltd. Room 701, Bldg. B Far East International Plaza No. 317 Xian Xia Road Shanghai, 200051 Tel: 86-21-6275-5700 Fax: 86-21-6275-5060
Kokomo
2767 S. Albright Road Kokomo, Indiana 46902 Tel: 765-864-8360 Fax: 765-864-8387
France
Microchip Technology SARL Parc d'Activite du Moulin de Massy 43 Rue du Saule Trapu Batiment A - ler Etage 91300 Massy, France Tel: 33-1-69-53-63-20 Fax: 33-1-69-30-90-79
Los Angeles
18201 Von Karman, Suite 1090 Irvine, CA 92612 Tel: 949-263-1888 Fax: 949-263-1338
China - Shenzhen
Microchip Technology Consulting (Shanghai) Co., Ltd., Shenzhen Liaison Office Rm. 1315, 13/F, Shenzhen Kerry Centre, Renminnan Lu Shenzhen 518001, China Tel: 86-755-2350361 Fax: 86-755-2366086
New York
150 Motor Parkway, Suite 202 Hauppauge, NY 11788 Tel: 631-273-5305 Fax: 631-273-5335
Germany
Microchip Technology GmbH Gustav-Heinemann Ring 125 D-81739 Munich, Germany Tel: 49-89-627-144 0 Fax: 49-89-627-144-44
San Jose
Microchip Technology Inc. 2107 North First Street, Suite 590 San Jose, CA 95131 Tel: 408-436-7950 Fax: 408-436-7955
Hong Kong
Microchip Technology Hongkong Ltd. Unit 901-6, Tower 2, Metroplaza 223 Hing Fong Road Kwai Fong, N.T., Hong Kong Tel: 852-2401-1200 Fax: 852-2401-3431
Italy
Microchip Technology SRL Centro Direzionale Colleoni Palazzo Taurus 1 V. Le Colleoni 1 20041 Agrate Brianza Milan, Italy Tel: 39-039-65791-1 Fax: 39-039-6899883
Toronto
6285 Northam Drive, Suite 108 Mississauga, Ontario L4V 1X5, Canada Tel: 905-673-0699 Fax: 905-673-6509
India
Microchip Technology Inc. India Liaison Office Divyasree Chambers 1 Floor, Wing A (A3/A4) No. 11, O'Shaugnessey Road Bangalore, 560 025, India Tel: 91-80-2290061 Fax: 91-80-2290062
United Kingdom
Arizona Microchip Technology Ltd. 505 Eskdale Road Winnersh Triangle Wokingham Berkshire, England RG41 5TU Tel: 44 118 921 5869 Fax: 44-118 921-5820
03/01/02
DS39025F-page 22
2002 Microchip Technology Inc.


▲Up To Search▲   

 
Price & Availability of PIC16F874

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X